<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-civilized-dormitory-edit" th:object="${civilizedDormitory}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
            <div class="form-group">	
                <label class="col-sm-3 control-label">宿舍号：</label>
                <div class="col-sm-8">
                    <select id="dormitoryNumber" name="dormitoryNumber" class="form-control" data-placeholder="可一次选择多个">
                    	<option th:value="*{dormitoryNumber}" th:text="*{dormitoryNumber}"></option>
					</select>
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">对应日期：</label>
                <div class="col-sm-8">
                    <input id="belongDate" name="date" th:value="${#dates.format(teacherCivilizedDormitory.belongDate,'yyyy-MM-dd')}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script th:src="@{/ajax/libs/select/select2.js}"></script>
    <script type="text/javascript">
    	$(function(){
	    	var prefix = ctx + "module/teacher/civilized-dormitory"
			
	    	layui.use('laydate', function(){
			    var laydate = layui.laydate;
			    laydate.render({
			    	elem: '#belongDate'
			    });
			});
	    	
	    	$("#dormitoryNumber").select2({
				ajax: {
			        type:'GET',
			        url: prefix + "/queryDormFormatSelect2",
			        delay: 250,
			        cache: true,
			        processResults: function (data, params) {
			        	data.results.forEach(function(item){
			        		item.id = item.text;
			        	});
			        	return data;
				    }
			    }, 
			});
	    	
	    	$("#form-civilized-dormitory-edit").validate({
				rules:{
					xxxx:{
						required:true,
					},
				},
				submitHandler: function(form) {
					console.log($(form).serialize());
					$.operate.save(prefix + "/edit", $(form).serialize());
				}
			});
    	});
	</script>
</body>
</html>
